package com.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
@WebServlet("/shopcarServlet")
public class shopcarServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");
        String javacheck = req.getParameter("javacheck");
        String Oraclecheck = req.getParameter("Oraclecheck");
        String Strutscheck = req.getParameter("Strutscheck");
//        if ("java".equals(javacheck)){
//            Cookie check1 = new Cookie("check1", javacheck);
//            check1.setMaxAge(60*60*24*7);
//            resp.addCookie(check1);
//        }
//        if ("Oracle".equals(Oraclecheck)){
//            Cookie check2 = new Cookie("check2", Oraclecheck);
//            check2.setMaxAge(60*60*24*7);
//            resp.addCookie(check2);
//        }
//        if ("Struts".equals(Strutscheck)){
//            Cookie check3 = new Cookie("check3", Strutscheck);
//            check3.setMaxAge(60*60*24*7);
//            resp.addCookie(check3);
//        }
        HttpSession session = req.getSession();
        session.setAttribute("javacheck",javacheck);
        session.setAttribute("Oraclecheck",Oraclecheck);
        session.setAttribute("Strutscheck",Strutscheck);
        String contextPath = req.getContextPath();
        resp.sendRedirect("/webWork/step2.html");
//        req.getRequestDispatcher("/step2.html").forward(req,resp);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}